package projectwork;


import java.io.IOException;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;


public class TestScript extends projectFunction {
	
	//*********************TestCases for Login to SFDC
	
	//**********LOGIN**************8888

	public static void login() throws InterruptedException, IOException{
		String DT = "C:/Users/alubana/Google Drive/Framework/Testdata/TestData.xls";
		//String DT="C:/Users/amandeep/Google Drive/Framework/Testdata/TestData.xls";
		String recData[][] = null;
		recData = projectFunction.readData(DT, "Sheet1");
		
			
			
		String UN = recData[1][1];
		String PW = recData[1][2];
		String URL = recData[1][3];
		// Type the URL
				driver.get(URL);
			

				// Maximize the browser
				driver.manage().window().maximize();
				

				/* enter user name for user name field*/
				enterText("//*[@id='username']", UN , "UserName");


				//Verify the home page logo is being displayed
				ISShown("//*[@id='phHeaderLogoImage']","HomePageLogo"); 
	}
	
	
	//************TC:- Test the Remember Me**************** 
	public static void RememberMe() throws IOException{
		
		
		String DT = "C:/Users/alubana/Google Drive/Framework/Testdata/TestData.xls";
		//String DT="C:/Users/amandeep/Google Drive/Framework/Testdata/TestData.xls";
		String recData[][] = null;
		recData = projectFunction.readData(DT, "Sheet1");
		
			
			
		String UN = recData[1][1];
		String PW = recData[1][2];
		String URL = recData[1][3];
		
		System.out.println("The Username is :"+recData[1][1]);
		System.out.println("The Password is :"+recData[1][2]);
		System.out.println("The URL is :"+recData[1][3]);


		// Type the URL
		driver.get(URL);
	

		// Maximize the browser
		driver.manage().window().maximize();
		

		/* enter user name for user name field*/
		enterText("//*[@id='username']", UN , "UserName");


		/* Enter the password for password field */
		enterText("//*[@id='password']", PW, "Password");
		
		//click on remember 
		clickObject("//*[@id='rememberUn']","Remember Me");

		/*Click on Login object */
		clickObject("//*[@id='Login']", "Login button");
		
		
		//Verify the home page logo is being displayed
		ISShown("//*[@id='phHeaderLogoImage']","HomePageLogo");
		
		//Click on the username
		clickObject("//*[@id='userNavButton']", "Click Username on Home page");
		clickObject("//*[@id='userNav-menuItems']/a[4]", "Logout");
		
		//Verify the Relogintpage is being displayed
				ISShown("//*[@id='logo']","reloginpage");
        
		//Verify Username field is havoing the saved username				
				verifyContent("//*[@id='username']","Username","tuser1@inidia.com");
				
				
		driver.close();
	}

             //***********TC:Login Error Message*********//
	
	public static void LoginErrorMessage() throws IOException{
		String DT = "C:/Users/alubana/Google Drive/Framework/Testdata/TestData.xls";
		//String DT="C:/Users/amandeep/Google Drive/Framework/Testdata/TestData.xls";
		String recData[][] = null;
		recData = projectFunction.readData(DT, "Sheet1");
		
		
			
		String UN = recData[1][1];
		String URL = recData[1][3];
		// Type the URL
				driver.get(URL);
			

				// Maximize the browser
				driver.manage().window().maximize();
				

				/* enter user name for user name field*/
				enterText("//*[@id='username']", UN , "UserName");
				//Clears the password field
				Clearfld("//*[@id='password']","Password");
				/*Click on Login object */
				clickObject("//*[@id='Login']", "Login button");
               
				//Error message is displayed
				LoginErrorMsgValidation("//*[@id='error']","Error message","Please enter your Password.");
				driver.close();
	}
	
	
	//******************** TC:- Reset Password***************************************
	
	public static void Resetpwd(String xpathobj,String objname ) throws IOException{
	
	String DT = "C:/Users/alubana/Google Drive/Framework/Testdata/TestData.xls";
	//String DT="C:/Users/amandeep/Google Drive/Framework/Testdata/TestData.xls";
	String recData[][] = null;
	recData = projectFunction.readData(DT, "Sheet1");
	
	
		

	String URL = recData[1][3];
	String email=recData[2][4];
	// Type the URL
			driver.get(URL);
		
			// Maximize the browser
			driver.manage().window().maximize();
			//Click on forgot password link
			clickObject("//*[@id='forgot']/span[1]/a","Forgot your password?");
			//Click on 
			enterText("//*[@id='forgot']/span[1]/a", email , "Email");
			clickObject("//*[@id='un']","email");
			driver.close();
			
}
	
	//**********************
	
	//***************To get the values from the DataTable**************************
	/**
	public static void GetDataTable(){
		
		
			

		String URL = "http://datatables.net/release-datatables/extras/TableTools/index.html";
		
		driver.get(URL);
		
		// Maximize the browser
		driver.manage().window().maximize();
		List<WebElement> tt= driver.findElements(By.xpath("//*[@id='example']")).findElements(By.tagName("tr"));
	}**/
	}
	
	
		

